from dataclasses import dataclass


@dataclass()
class Engine:
    # 气缸数量
    cylinder: int
    # 发动机排量
    displacement: int
    # 是否带涡轮蒸鸭
    have_turbine: bool


@dataclass()
class CarSeat:
    color: str
    # 材料
    material: str
    # 是否带通风功能
    ventilation: bool
    # 是否打开通风功能
    ventilation_stat: bool = False

    def open_ventilation(self):
        if self.ventilation:
            self.ventilation_stat = True
            print("座椅通风已打开")
        else:
            print("此车不带通风功能")


@dataclass()
class Car:
    make: str
    model: str
    year: str
    engine: Engine
    car_seat: CarSeat
    odometer: int = 0

    def set_odometer(self, odometer):
        self.odometer = odometer

    def driver(self, a):
        self.odometer += a


def product_car():
    blue_whale = Engine(4, 2, True)
    seat = CarSeat('蓝色', '真皮', True)
    my_univ = Car('长安', 'UNIV', '2023', blue_whale, seat)
    return my_univ


if __name__ == '__main__':
    car = product_car()
    seat = car.car_seat
    print(car)
    seat.open_ventilation()
    print(car)